﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DataAccess;

public partial class ExpertManager_AssignTask : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Txtime.Text = DateTime.Now.ToString();
        DropDownList1.SelectedIndex = 1; 
    }


    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Session["provinceId"] = DropDownList1.SelectedItem.Value;
        //TblCustomer cus = new TblCustomer();
        //gvcustomer.DataSource = TblCustomer.FetchByParameter(TblCustomer.Columns.ProvinceId, SubSonic.Comparison.Equals, Session["provinceId"].ToString());
        //gvcustomer.DataBind();
    }

    protected void gvcus_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        //DataTable dt = new DataTable();
        //dt.Columns.Add("CusId");
        //dt.Columns.Add("Type");
        //dt.Columns.Add("Description");
        //dt.Columns.Add("RegDate");
        //dt.Columns.Add("ExpertId");
        int index = Convert.ToInt32(e.CommandArgument);
        Session["Id"] = Convert.ToInt32(gvcustomer.Rows[index].Cells[1].Text);
        switch (e.CommandName)
        {
            case "Assign":
                MultiView1.ActiveViewIndex = 0;

                //DataRow dr;
                //dr=dt.NewRow();
                //dr["CusId"] = Session["Id"];
                //dr["Type"]=

                break;
        }
    }
    //protected void GrdGet_RowCommand(object sender, GridViewCommandEventArgs e)
    //{
    //    //GridView GrdGet = (GridView)gvcustomer.Ite.FindControl("GrdGet");

    //    switch (e.CommandName)
    //    {
    //        case "Assign":
    //             int index = Convert.ToInt32(e.CommandArgument);
    //            //Session["CustId"] = Convert.ToInt32(GrdGet.Rows[1].Cells[0].Text);

    //                 MultiView1.ActiveViewIndex=0;
    //            TblCusFolder folder = new TblCusFolder();
    //            LblInfo.Text = "Hello";
    //            break;
    //    }
    //}

    protected void GrdGet_RowEditing(object sender, GridViewEditEventArgs e)
    {

        GridView GrdGet = (GridView)gvcustomer.FindControl("GrdGet");
        GrdGet.EditIndex = e.NewEditIndex;
        //Bind data to the GridView control.
        GrdGet.DataBind();


    }

    protected void gvCust_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            SqlDataSource ctrl = e.Row.FindControl("SqlCustomer") as SqlDataSource;
            if (ctrl != null && e.Row.DataItem != null)
            {
                ctrl.SelectParameters["Telephone"].DefaultValue =
                gvcustomer.DataKeys[e.Row.RowIndex].Value.ToString();

            }
        }

    }

    protected void BtnOk_Click(object sender, EventArgs e)
    {

        SubSonic.Query Qr = TblCusFolder.CreateQuery();
        Qr.QueryType = SubSonic.QueryType.Update;
        Qr.AddUpdateSetting(TblCusFolder.Columns.ExpertId, DrpExpert.SelectedValue);
        Qr.AddUpdateSetting(TblCusFolder.Columns.RegDate, Txtime.Text);
        Qr.WHERE(TblCusFolder.Columns.Id, SubSonic.Comparison.Equals, Session["Id"]);
        Qr.Execute();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Page.Response.Redirect(Page.Request.Url.ToString(), true);
    }
}



      